Skip to content

Make Data.List.NonEmpty.toUnfoldable and Data.List.Lazy.NonEmpty.toUnfoldable work with Unfoldable1 #220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

UnrelatedString
Copy link

Description of the change

Modified toUnfoldable in Data.List.NonEmpty and Data.List.Lazy.NonEmpty to have the signature toUnfoldable :: forall f. Unfoldable1 f => NonEmptyList ~> f, and reimplemented it accordingly. Additionally added tests covering all four toUnfoldables, since apparently there were no such tests in the existing codebase.

The motivation for this PR is that some users may hypothetically wish to convert known non-empty lists into other structures which cannot be empty. This can be addressed unobtrusively because Unfoldable1 is a superclass of Unfoldable; the old type signature is completely compatible with the new implementation. For lack of a real use case, I was inspired to contribute this change when developing an even more superfluous package of my own which pervasively concerns itself with laziness in unfoldables.

Did not bump the version--although I don't think I could have made any breaking changes, I still changed the types of two functions in the public API (and the only relevant tests are ones I wrote), and either way I assume versioning decisions are best left to package maintainers.


Checklist:

  • Added the change to the changelog's "Unreleased" section with a reference to this PR (e.g. "- Made a change (#0000)")
  • Linked any existing issues or proposals that this pull request should close
  • Updated or added relevant documentation
  • Added a test for the contribution (if applicable)

@UnrelatedString
Copy link
Author

Have not added or updated any documentation because there is no documentation in either of the affected modules. I'm tempted to copy all of the documentation over from vanilla Data.List, but I assume this has not already been done to avoid future effort spent on mirroring any future documentation changes?

Fixed my bad guess for PR name
@UnrelatedString
Copy link
Author

Instead of replacing the existing toUnfoldable, this could also provide a separate toUnfoldable1 like in Data.Array.NonEmpty. Seems a bit redundant to me, but I suppose it would also perform a bit better for Unfoldable containers if they implement Unfoldable1 with an adapter to unfoldr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant